<!-- src/components/Search.vue -->
<template>
  <div class="search-box">
    <input type="text" v-model="searchQuery" placeholder="搜索..." @input="handleSearch" />
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue';

const searchQuery = ref('');

const emit = defineEmits(['search']);//自定义事件

const handleSearch = () => {
  emit('search', searchQuery.value);
};
</script>

<style scoped lang="scss">
.search-box {
  position: fixed;
  bottom: 135px;
  right: 90px; /* 调整到 global-search 按钮的左侧 */
  width: 300px; /* 调整宽度 */
  height: 40px; /* 调整高度 */
  background-color: #fff;
  border: 1px solid #ccc;
  border-radius: 8px; /* 圆角 */
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); /* 更深的阴影 */
  padding: 5px 10px;
  box-sizing: border-box;
  transition: opacity 0.3s ease, transform 0.3s ease; /* 添加过渡效果 */
  transform: translateX(20px); /* 初始位置 */
  z-index: 1000; /* 确保在其他内容之上 */

  input {
    width: 100%;
    height: 100%;
    border: none;
    outline: none;
    font-size: 14px;
    color: #0d1216;
    background-color: transparent;
  }
}
.slide-enter-active,
.slide-leave-active {
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.slide-enter-from,
.slide-leave-to {
  opacity: 0;
  transform: translateX(20px);
}

.slide-enter-to,
.slide-leave-from {
  opacity: 1;
  transform: translateX(0);
}
</style>
